module.exports = function ($scope, $state, $resource, $modal, toaster, $stateParams) {
	$scope.myKeyup = function (e) {
		//IE 编码包含在window.event.keyCode中，Firefox或Safari 包含在event.which中
		var keycode = window.event ? e.keyCode : e.which;
		if (keycode == 13) {
			$scope.loadlist();
		}
  };
  var wxuid = $stateParams.wxuid;
  $scope.level = $stateParams.level;
  console.log($scope.level);
	/* 分页
   * ========================================= */
  $scope.maxSize = 5;            //最多显示多少个按钮
  $scope.bigCurrentPage = 1;      //当前页码
  $scope.itemsPerPage = 10; 
  $scope.searchform = {};
	$scope.loadlist = function () {
    var para = {
        pageNo:$scope.bigCurrentPage, 
        pageSize:$scope.itemsPerPage,
        wxuid:wxuid
    };
    para = angular.extend($scope.searchform, para);
		$resource('/api/as/mc/userrole/findZDDownList', {}, {}).save(para, function (res) {
			if (res.errcode === 0) {
        $scope.objs = res.data.results;
        $scope.bigTotalItems = res.data.totalRecord;
			} else {
				toaster.error({ title: '', body: res.errmsg });
			}
		});
	}

	$scope.loadlist();

	

	//查看下集
	$scope.seeLevel = function (obj) {
      console.log(obj.wxuid);
      $state.go('app.skwxBDistributorList', {'wxuid' : obj.wxuid, 'level' : '2'});
  }
  // 查看上级
  $scope.seeALevel = function(obj){
      console.log(obj.pwxuid);
      $state.go('app.skwxADistributorList', {'pwxuid' : obj.pwxuid, 'level' : obj.level});
  }
  // 返回一级分销商
  $scope.back = function(obj){
      $state.go('app.skwxADistributorList');
  }
	
};